﻿@{
    ViewBag.Title = "新增联系人";
}

@model FMS.UI.Areas.Factory.ViewModel.Factory_Machines_Supplier_Contact
@section headsecion{
    <style type="text/css">
        body {
            margin: 0;
            align-self: center;
        }

        li {
            margin: 0;
            padding: 0;
            list-style-type: none;
        }

        .tbList {
            border: 1px solid #ddd;
            height: 99.5%;
            border-collapse: collapse;
            margin: 0;
            padding: 0;
            width: 100%;
            border-top-width: 0;
            border-bottom-width: 0;
            border-left-width: 0;
            border-right-width: 0;
        }

            .tbList td, th {
                border: 1px solid #ddd;
                padding: 0 5px;
                width: 60px;
                height: 35px;
            }

        #tdName {
            text-align: center;
        }

        #form0 {
            margin: 0;
            padding: 0;
        }

        .ui-autocomplete {
            max-height: 110px; /*高度值*/
            overflow-y: auto; /*超过高度出现滚动条*/
            /* prevent horizontal scrollbar */
            overflow-x: hidden; /*横向超出隐藏，如果要出现横向滚动，设置为auto即可*/
        }
    </style>
    <link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-ui-1.8.24.min.js"></script>
    <script type="text/javascript">
        $(function () {
            // 去掉所有input的autocomplete, 显示指定的除外
            $('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');
            $("#gongying").autocomplete({
                // 通过函数自定义处理数据源
                source: function (request, response) {
                    // request对象只有一个term属性，对应用户输入的文本
                    // response是一个函数，在你自行处理并获取数据后，将JSON数据交给该函数处理，以便于autocomplete根据数据显示列表
                    var url = "/Factory/FactoryContact/GongYingShang?term=" + request.term;
                    $.ajax({
                        'url': url,
                        dataType: 'json',
                        success: function (dataObj) {
                            var data = jQuery.makeArray(dataObj);
                            var ssd = $.map(data, function (item) {
                                return {
                                    value: item.value,
                                    label: item.label
                                }
                            });
                            response(ssd);
                        }
                    });
                },
                select: function (event, ui) {
                    // ui对象只有一个item属性，对应数据源中被选中的对象
                    $("#gongying").val(ui.item.label);
                    $("#gys").val(ui.item.value);
                    // 必须阻止默认行为，因为autocomplete默认会把ui.item.value设为输入框的value值
                    event.preventDefault();
                },
                mustMatch: true
            });
        });

        function Begin() {

        };

        function Complete(xhrobj) {
            $.msgProcess(xhrobj.responseText, function () {
                $.globalHelper.closeCommonWindow();
                $.globalHelper.reloadSeletecTabDataGrid();
            });
        };
    </script>
}
@using (Ajax.BeginForm(new AjaxOptions()
{
    OnBegin = "Begin",
    OnComplete = "Complete"

}))
{
    <table id="tbList" class="tbList">
        <tr>
            <td id="tdName">@Html.DisplayNameFor(o => o.Supplier_Id)</td>
            <td>
                @Html.TextBoxFor(o => o.Supplier_Id_Name, new { id = "gongying" })@Html.ValidationMessageFor(o => o.Supplier_Id_Name)
                @Html.HiddenFor(o => o.Supplier_Id, new { id = "gys" })@Html.ValidationMessageFor(o => o.Supplier_Id)
            </td>
        </tr>

        <tr>
            <td id="tdName">@Html.DisplayNameFor(o => o.contact_Name) </td>
            <td> @Html.TextBoxFor(o => o.contact_Name)@Html.ValidationMessageFor(o => o.contact_Name)</td>
        </tr>
        <tr>
            <td id="tdName">@Html.DisplayNameFor(o => o.contact_Phone)</td>
            <td>@Html.TextBoxFor(o => o.contact_Phone)@Html.ValidationMessageFor(o => o.contact_Phone)</td>
        </tr>
        <tr>
            <td id="tdName">@Html.DisplayNameFor(o => o.contact_Address)</td>
            <td>@Html.TextBoxFor(o => o.contact_Address)@Html.ValidationMessageFor(o => o.contact_Address)</td>
        </tr>


        <tr>

            <td colspan="2" style="text-align: center; border: 0 solid white; margin-bottom: 0"><input type="submit" value="确定" style="height: 27px; width: 68px; cursor: pointer" /></td>
        </tr>
    </table>
}
